/*
import 'dart:async';
import 'dart:math';

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:lib_core/lib_core.dart';
import 'package:lib_ui/lib_ui.dart';
import 'package:lib_ui/widget/common_text_field.dart';
import 'package:lib_ui/widget/main_button.dart';

import '../../logic/test/test_login_logic.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMixin {
  late TabController _tabController;
  final horizontalMargin = 15.0;
  Timer? timer;
  final logic = Get.put(TestLoginLogic());

  //
  final typePwd = 0;
  final typeCode = 1;
  final currentType = 0.obs;

  //
  final max = 4;
  final countDown = 0.obs;

  //

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: TransparentAppBar(
        automaticallyImplyLeading: false,
      ),
      body: Container(
        padding: const EdgeInsets.symmetric(vertical: 10),
        child: Column(
          children: [
            UIAssets.images.iconLogo.image(width: 80),
            _commonDivider(),
            _buildTabBar(),
            _commonDivider(),
            _buildInput(),
            _commonDivider(height: 20),
            _buildProtocol(),
            _commonDivider(height: 20),
            _buildLoginBtn(),
          ],
        ),
      ),
    );
  }

  Widget _buildTabBar() {
    List<Widget> buildTabItem() {
      var list = <Tab>[const Tab(text: '账号登录'), const Tab(text: '验证码登录')];
      return list;
    }

    return Container(
      height: 40,
      alignment: Alignment.center,
      padding: EdgeInsets.symmetric(horizontal: Get.width * 0.2),
      child: TabBar(
        tabs: buildTabItem(),
        unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.normal, color: Colors.grey),
        labelStyle: const TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
        indicator: MaterialIndicator(height: 2),
        controller: _tabController,
        dividerHeight: 0,
        onTap: (index) {
          currentType.value = index;
        },
      ),
    );
  }

  Widget _buildInput() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: horizontalMargin),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          CommonTextField(
            type: CommonTextFieldType.clear,
            keyboardType: TextInputType.text,
            text: logic.account.value,
            onTextChanged: (str) {
              logic.account.value = str;
            },
          ),
          const SizedBox(
            height: 10,
          ),
          Obx(() {
            if (currentType.value == typePwd) {
              return CommonTextField(
                key: const ValueKey(1),
                type: CommonTextFieldType.password,
                keyboardType: TextInputType.text,
                text: logic.password.value,
                onTextChanged: (str) {
                  logic.password.value = str;
                },
              );
            } else {
              return CommonTextField(
                key: const ValueKey(2),
                type: CommonTextFieldType.custom,
                customWidget: GestureDetector(
                  onTap: () {
                    if (countDown.value == 0) {
                      '验证码已发送'.showSuccess();
                      timer = Timer.periodic(const Duration(seconds: 1), (_) {
                        if (countDown.value <= max) {
                          countDown.value++;
                        } else {
                          timer?.cancel();
                          countDown.value = 0;
                        }
                      });
                    } else {
                      '请等待'.showError();
                    }
                  },
                  child: Text(
                    max - countDown.value == -1 || countDown.value == 0 ? '获取验证码' : '获取验证码（${max - countDown.value}）',
                    style: TextStyle(color: max - countDown.value == -1 || countDown.value == 0 ? Colors.black : Colors.grey),
                  ),
                ),
                onTextChanged: (str) {},
              );
            }
          }),
        ],
      ),
    );
  }

  Widget _buildProtocol() {
    return Container(
      alignment: Alignment.centerLeft,
      margin: EdgeInsets.only(left: horizontalMargin),
      child: Wrap(
        direction: Axis.horizontal,
        crossAxisAlignment: WrapCrossAlignment.center,
        children: [
          SizedBox(
            width: 24,
            height: 24,
            child: Obx(() {
              return Checkbox(
                value: logic.isAgreed.value,
                shape: const CircleBorder(),
                side: const BorderSide(
                  width: 1.5,
                  color: ColorName.textHint,
                ),
                activeColor: ColorName.primary,
                onChanged: (value) {
                  logic.isAgreed.value = value ?? false;
                },
              );
            }),
          ),
          const SizedBox(width: 5),
          Text.rich(
            TextSpan(
              text: '我已阅读并同意',
              style: const TextStyle(fontSize: 12, color: ColorName.textPrimary),
              children: [
                TextSpan(
                  text: '《用户协议》',
                  style: const TextStyle(fontSize: 12, color: ColorName.primary),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      '同意'.showSuccess();
                    },
                  children: [
                    TextSpan(
                      text: '及',
                      style: const TextStyle(fontSize: 12, color: ColorName.textPrimary),
                      children: [
                        TextSpan(
                          text: '《隐私协议》',
                          style: const TextStyle(fontSize: 12, color: ColorName.primary),
                          recognizer: TapGestureRecognizer()
                            ..onTap = () {
                              '知道'.showSuccess();
                            },
                        )
                      ],
                    )
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget _buildLoginBtn() {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.symmetric(horizontal: horizontalMargin),
      child: Obx(() {
        var canClick = false;
        if (currentType.value == typeCode) {
          canClick = logic.account.value.isNotEmpty && logic.verifyCode.value.isNotEmpty;
        } else {
          canClick = logic.account.value.isNotEmpty && logic.password.value.isNotEmpty;
        }
        return MainButton(
            enabled: canClick,
            backgroundColor: ColorName.primary,
            textColor: Colors.white,
            borderSide: BorderSide.none,
            text: '登录',
            onClick: () async {
              */
/*logic.loginByPwd((user) async {
                '登录成功'.showSuccess();
              });*//*

              BoostNavigator.instance.push('native/test1');
              // BoostNavigator.instance.push('main');
            });
      }),
    );
  }

  Widget _commonDivider({double height = 10.0}) {
    return  SizedBox(height: height);
  }

  @override
  void dispose() {
    timer?.cancel();
    super.dispose();
  }
}
*/
